package edu.sctu.zhengsenwen.month201506.day20150607.StudentsAndCanteen;


import java.util.Scanner;

/**
* Created by user15 on 2015/6/7.
*/
public class Students {

    String name;
    String sex;
    int number;
    StudentCard studentCard;
    Seat seat;

    //学生选择打饭窗口
    public LunchWindow ChooseWindow(Canteen canteen) {

        System.out.println("There are three lunch-windows,please input 1,2 or 3 to choose your window");

        Scanner inputNumber = new Scanner(System.in);

        int choice = inputNumber.nextInt();

        LunchWindow lunchWindow = null;

        switch (choice) {


            case 1:
                lunchWindow = canteen.lunchWindows[0];
                break;
            case 2:
                lunchWindow = canteen.lunchWindows[1];
                break;
            case 3:
                lunchWindow = canteen.lunchWindows[2];
                break;

        }

            System.out.println("This window has " + lunchWindow.onlineStudents + " people are waiting in line");

        return lunchWindow;

    }



    //学生在窗口选择饭菜
    public float chooseDish(LunchWindow lunchWindow) {

        Scanner input = new Scanner(System.in);

        System.out.println("This window has these dishes：\n");

        System.out.println(lunchWindow.dishes.keySet());

        String dishName = null;


        for (String check = "no"; check.equals("yes") != true; check = input.next()) {

            System.out.println("Please input the name of dish to check if you want to buy it.");

            dishName = input.next();

            System.out.println("The color of the dish：" + lunchWindow.dishes.get(dishName).color + "\tThe price of the dish：" + lunchWindow.dishes.get(dishName).price);

            System.out.println("Please input 'yes' or 'no'  to ensure your choice.");

        }

        System.out.println("The rice costs 0.5RMB per tael , and please input how much rice do you want to buy?");

        float finalPrice = input.nextFloat() * lunchWindow.rice.price + lunchWindow.dishes.get(dishName).price;

        System.out.println("The money for lunch： "+finalPrice);

        return finalPrice;

    }




    //学生点完菜刷卡
    public void payForMeal(float finalPrice,float balance){

        balance = balance - finalPrice;

        System.out.println("The student's balance.");

        System.out.println(balance);

    }



        //学生选择座位
    public void chooseSeat(Canteen canteen) {

        Scanner input = new Scanner(System.in);

        System.out.println("\n");

        System.out.println("There are 20 seats,please input 1~20 to decide which one would you like to chose.");

        for (int i = 0; i < 20; i++) {

            int choice = input.nextInt();

            if (canteen.seats[choice - 1].statement == 1) {

                System.out.println("Sorry,this seat is already seated by someone,please choose another seats.：");
            } else {
                System.out.println("This seat is null,just do it!");

                seat = canteen.seats[choice - 1];
                break;
            }

        }
    }
}


